package com.blog.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.blog.po.User;
import com.blog.service.UserService;
import com.opensymphony.xwork2.ActionSupport;


public class Register extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String username;
	private String password;
	private String repassword;
	private String nickname;
	private String question;
	private String answer;
	@Autowired
	private UserService registerService;
	
	public UserService getRegisterService() {
		return registerService;
	}
	public void setRegisterService(UserService registerService) {
		this.registerService = registerService;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getRepassword() {
		return repassword;
	}
	public void setRepassword(String repassword) {
		this.repassword = repassword;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	public String getAnswer() {
		return answer;
	}
	public void setAnswer(String answer) {
		this.answer = answer;
	}
		
	
	public String execute(){
		System.out.println(username+"--"+nickname+"--"+password+"--"+question+"--"+answer);
		User user=new User();
		user.setUsername(username);
		user.setPassword(password);
		user.setNickname(nickname);
		user.setQuestion(question);
		user.setAnswer(answer);
		if(registerService.regesterUser(user)){
			return "success";
		}
		return ERROR;
	}
}
